#include "bsp_mcuid.h"
#include "bsp_usart.h"

uint32_t idAddr[] = {0x1FFFF7AC,  /*STM32F0唯一ID起始地址*/
                     0x1FFFF7E8,  /*STM32F1唯一ID起始地址*/
                     0x1FFF7A10,  /*STM32F2唯一ID起始地址*/
                     0x1FFFF7AC,  /*STM32F3唯一ID起始地址*/
                     0x1FFF7A10,  /*STM32F4唯一ID起始地址*/
                     0x1FF0F420,  /*STM32F7唯一ID起始地址*/
                     0x1FF80050,  /*STM32L0唯一ID起始地址*/
                     0x1FF80050,  /*STM32L1唯一ID起始地址*/
                     0x1FFF7590,  /*STM32L4唯一ID起始地址*/
                     0x1FF0F420}; /*STM32H7唯一ID起始地址*/

/*获取MCU的唯一ID*/
void GetSTM32MCUID(uint32_t *id, MCUTypedef type)
{
    if (id != NULL) {
        id[0] = *(volatile uint32_t *)(idAddr[type]);
        id[1] = *(volatile uint32_t *)(idAddr[type] + 4);
        id[2] = *(volatile uint32_t *)(idAddr[type] + 8);
    }
}

// 获取芯片Flash大小
uint16_t GetFlashSize(void)
{
    uint16_t stm32_Flash_Size;
    stm32_Flash_Size = *(uint16_t *)(0x1FFFF7E0); // 闪存容量寄存器
    return stm32_Flash_Size;
}
